#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout);
#define pb push_back

int read(){
	int x = 0,sgn = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;
	for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x*sgn;
}

const int N = 5e5+10;

int las[N],n,m,K,bel[N],tot,vis[N],ttot,col[N],cnt;
vector<int> al[N];
map<pii,int> mp;
vector<int> G[N],c0,c1,T[N],pot;
vector<pii> e[N];
bool can[N],fl;
ll ans;

void dfs(int x,int c){
	vis[x] = c; if(fl) return;if(c == 2) c0.pb(x); else c1.pb(x);
	for(int y : G[x]){
		if(!vis[y]) dfs(y,3-c);
		else if(vis[y] == vis[x]) fl = 1;
	}
}

void Dfs(int x,int c){
	vis[x] = c; pot.pb(x); if(fl) return;
	for(int y : T[x]){
		if(!vis[y]) Dfs(y,3-c);
		else if(vis[y] == vis[x]) fl = 1;
	}
}

int main (){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	n = in,m = in; K = in;
	for(int i = 1;i <= n;i++) bel[i] = in,al[bel[i]].pb(i);
	for(int i = 1,u,v;i <= m;i++){
		u = in,v = in;
		if(bel[u] ^ bel[v]){
			if(bel[u] > bel[v]) swap(u,v);
			pii t = pii(bel[u],bel[v]);
			if(mp.count(t)) e[mp[t]].pb(pii(u,v));
			else mp[t] = ++tot,e[mp[t]].pb(pii(u,v));
		}else G[u].pb(v), G[v].pb(u);
	}ttot = 0;
	for(int i = 1;i <= K;i++){
		if(!al[i].size()) {ttot++;can[i] = 1;continue;}
		fl = 0;
		for(int t : al[i])
			if(!vis[t]){
				dfs(t,2); if(fl) continue;
				++cnt; for(int x : c0) col[x] = cnt;
				if(c1.size()) {++cnt; for(int x : c1) col[x] = cnt; T[cnt].pb(cnt-1);T[cnt-1].pb(cnt);}
				c0.clear(); c1.clear();
			}
		if(!fl) can[i] = 1,ttot++;
	} memset(vis,0,sizeof(vis));
	ans = 1ll * ttot * (ttot-1) / 2;
	for(map<pii,int> :: iterator it = mp.begin();it != mp.end();it++){
		pii d = it -> fi; 
		if(!can[d.fi] || !can[d.se] || !al[d.fi].size() || !al[d.se].size()) continue;
		int num = it -> se;  vector<int> rep;
		for(pii ed : e[num]){int u = col[ed.fi],v = col[ed.se]; T[u].pb(v); T[v].pb(u);rep.pb(u),rep.pb(v);}
		fl = 0; for(int x : rep) if(!vis[x]) {Dfs(x,2);if(fl) break;}
		if(fl) ans--;
		for(pii ed : e[num]) T[col[ed.fi]].pop_back(),T[col[ed.se]].pop_back();
		for(int x : pot) vis[x] = 0; pot.clear();
	}
	printf("%lld\n",ans);
	return 0;
}
